﻿using System;
using System.Management;

namespace Bing_Wallpaper_Downloader
{
    internal class Monitor
    {
        public static bool IsActive()
        {
            bool isActive = false;

            using (var managementObjectSearcher = new ManagementObjectSearcher("\\root\\wmi", "select * from WmiMonitorBasicDisplayParams"))
            {
                try
                {
                    var results = managementObjectSearcher.Get();

                    foreach (ManagementObject managementObject in results)
                    {
                        isActive = Convert.ToBoolean(managementObject["Active"]);
                    }
                }
                catch
                { }
            }

            return isActive;
        }
    }
}
